<?php

namespace App\Console\Commands;

use App\Lead;
use Illuminate\Console\Command;

class LeadsCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'lead:name';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Lead::where('owner_user_id',56)->where('project_id',26)->chunkById(100,function ($items){
            foreach ($items as $item){
               $leads= Lead::where('project_id',26)
                    ->where('mobile',$item->mobile)
                   ->where('owner_user_id','!=',56)
                    ->get();
               foreach ($leads as $lead){
                   $this->info($lead->leads_id);
                   $lead->delete();
               }
            }
        });
    }
}
